package com.gzx.qc.modular.voice.check.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.qc.modular.voice.check.entity.GzxVoiceCheckDetail;
import com.gzx.qc.modular.voice.check.entity.bo.GzxVoiceCheckEditBo;
import com.gzx.qc.modular.voice.check.entity.bo.GzxVoiceCheckQueryBo;
import com.gzx.qc.modular.voice.check.entity.vo.GzxVoiceCheckVo;
import com.gzx.qc.modular.voice.check.service.GzxVoiceCheckService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * @author zjt
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/qc/voice/check")
public class GzxVoiceCheckController {

    private final GzxVoiceCheckService voiceCheckService;

    /**
     * 导出质检
     */
    @PostMapping("/exportVoiceCheck")
    public void exportVoiceCheck(@RequestBody GzxVoiceCheckQueryBo voiceCheckQueryBo, HttpServletResponse response) {
        voiceCheckService.exportVoiceCheck(voiceCheckQueryBo, response);
    }

    /**
     * 分页查询质检记录
     *
     * @param voiceCheckQueryBo 查询条件
     * @return
     */
    @PostMapping("/pageList")
    public CommonResult<Page<GzxVoiceCheckVo>> pageList(@RequestBody GzxVoiceCheckQueryBo voiceCheckQueryBo) {
        return CommonResult.data(voiceCheckService.pageList(voiceCheckQueryBo));
    }

    /**
     * 修改违规状态
     *
     * @param voiceCheckEditBo 查询条件
     * @return
     */
    @CommonLog("修改违规状态")
    @PostMapping("/modifyViolationStatus")
    public CommonResult<Page<GzxVoiceCheckVo>> modifyViolationStatus(@RequestBody GzxVoiceCheckEditBo voiceCheckEditBo) {
        voiceCheckService.modifyViolationStatus(voiceCheckEditBo);
        return CommonResult.ok();
    }

    /**
     * 修改违规状态
     *
     * @param callId 查询条件
     * @return
     */
    @CommonLog("质检在detail表内查询关键词")
    @GetMapping("/detailKeyword/{callId}")
    public CommonResult<List<GzxVoiceCheckDetail>> detailKeywordByCallId(@PathVariable("callId") String callId) {
        return CommonResult.data(voiceCheckService.detailKeywordByCallId(callId));
    }

}
